/**
* 提现记录
*/
import React, { Component } from 'react';
import { View, StyleSheet, Text, Image, TouchableOpacity, FlatList, TextInput } from "react-native";
import { connect } from 'react-redux';
import { create_service } from '../../redux/index.js';
import { Contract } from '../../service/index.js';
import { Colors, Dimens, ImageRes } from '../../utils/Assets';
import { ProgressView } from '../custom/index'
import { Actions } from 'react-native-router-flux';
import { getStore } from '../../redux/index.js';
class ProfitWithdrawDetailView extends Component {

    constructor(props) {
        super(props);
        this.state = {
            loading: false
        }
        this.statusArr = { '0': '申请中', '1': '已审核', '2': '已驳回', '3': '打款中', '4': '已打款', '5': '打款失败' }
        this.userInfo = getStore().getState().auth.userInfo
    }

    componentDidMount() {
        this.getDetailData()
    }
    componentWillUnmount() {
    }
    getDetailData() {
        this.setState({ loading: true })
        this.props.dispatch(create_service(Contract.POST_USER_CASH_INFO, {
            token: this.userInfo.token,
            cash_id: this.props.cash_id,
        })).then((res) => {
            if (res) {
                this.detailData = res
            }
            this.setState({ loading: false })
        })
    }
    renderItem(title, value) {
        return (
            <View style={{ flexDirection: 'row', justifyContent: 'space-between', paddingVertical: 15 }}>
                <Text style={{ fontSize: 15, color: "#999999" }}>{title}</Text>
                <Text style={{ fontSize: 15, color: '#333333' }}>{value}</Text>
            </View>
        )
    }
    render() {
        return (
            <View style={styles.container}>
                {this.detailData && <View style={{ marginTop: 30, backgroundColor: "#ffffff", marginHorizontal: 15, borderRadius: 10 }}>
                    <Image source={ImageRes.profit_money} style={{ width: 48, height: 50, alignSelf: 'center', marginTop: 30 }}></Image>
                    <Text style={{ fontSize: 20, fontWeight: 'bold', marginVertical: 30, alignSelf: 'center' }}>
                        {`余额提现到 - ${this.detailData.bank_name}(${this.detailData.card_number})`}
                    </Text>
                    <View style={{ backgroundColor: Colors.bg_color, height: 1, marginHorizontal: 15 }}></View>
                    <View style={{ paddingHorizontal: 15 }}>
                        {this.renderItem('提现金额', this.detailData.amount)}
                        {this.renderItem('提现状态', this.statusArr[this.detailData.status.toString()])}
                        {this.renderItem('提现时间', this.detailData.create_time)}
                        {this.renderItem('提现银行', `${this.detailData.bank_name}(${this.detailData.card_number})`)}
                        {/* {this.renderItem('申请时间', this.detailData.estimated_time)} */}
                        {(this.detailData.status == '2' || this.detailData.status == '5') && this.renderItem('备注', this.detailData.status_message)}
                    </View>
                </View>}
                <ProgressView show={this.state.loading} />
            </View>
        )
    }
}
const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: Colors.bg_color,
    }
});
const ExportView = connect()(ProfitWithdrawDetailView);
module.exports.ProfitWithdrawDetailView = ExportView
